// pages/Visitor/showuser/showuser.js
var util = require('../../../utils/util.js');
var app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    dialog4: {
      hidden: true
    },
    updatetime: "",
    json: "",
    indate: "",
    state: "",
    title: "",
    str: "",
    customerName:"",
    communityName:"",
    buildingName:"",
    imgUrl:"",
    dz:"",
    lc:"",
    name:""
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    var that = this;
    var customer_no = wx.getStorageSync('developerfk');
    var data = { customer_no: customer_no, customer_type: "1" }
    util.ajax("post", "/smallRoutineController/selectFxcustomer", data, function (res) {
      debugger;
      var list = res.list;
      var customerName = list[0].customerName;
      var communityName = list[0].communityName;
      var buildingName = list[0].buildingName;
      var userurl = list[0].photoUrl;
 
      that.setData({ name: customerName });
      that.setData({ dz: communityName });
      that.setData({ lc: buildingName });

      that.setData({imgUrl: util.getBasePath() + "/ccCustomerApiController/previewPhoto?fileId=" + userurl,})
      console.log(that.imgUrl);

      

      if (res.list.auditStatus == 1) {
        that.setData({ indate: "审核通过" });
      } else {
        that.setData({ indate: "审核中" });
      }
     

    })

   
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  exit:function(){
    util.index("提示", "确定退出吗？");
  },
  update: function () {
    var that = this;
    var customer_no = wx.getStorageSync('developerfk');
    var data = { customer_no: customer_no, customer_type: "1" }
    util.ajax("post", "/smallRoutineController/selectFxcustomer", data, function (res) {
      debugger;
      var list = res.list;
      var customerName = list[0].customerName;
      var communityName = list[0].communityName;
      var buildingName = list[0].buildingName;
      var userurl = list[0].photoUrl;

      that.setData({ name: customerName });
      that.setData({ dz: communityName });
      that.setData({ lc: buildingName });

      that.setData({ imgUrl: util.getBasePath() + "/ccCustomerApiController/previewPhoto?fileId=" + userurl, })
      console.log(that.imgUrl);



      if (res.list.auditStatus == 1) {
        that.setData({ indate: "审核通过" });
      } else {
        that.setData({ indate: "审核中" });
      }
      

        wx.redirectTo({
          url: '../../../pages/Visitor/showuser/showuser'
        })
    })
      
    
  },
  button: function (event) {
    if (event.currentTarget.id == "审核中") {
      util.msg("提示", "请前往管理处审核");
    }
  }
})